import java.util.ArrayList;
import java.util.List;
import java.util.Random;


public class Liyh {
	public static void main(String[] args) {
//		int i = (int)(Math.random()*10);
////		Random rd = new Random();
////		System.out.println(rd.nextInt(10));
//		System.out.println(i);
		String ss = "1:2:3:4:";
		String[] arr = ss.split(":");
		for(int i=0;i<arr.length;i++){
			if(arr[i]!=null||arr[i]!=""){
				System.out.println(arr[i]);
			}
		}
	}

	public static String[] splitString(String str,char delimiter){
		char[] chars = str.toCharArray();
		int flag = 0;
		//定义一个List来存放截取的字符串
		List<String> list = new ArrayList<String>();
		for(int i = 0;i<chars.length;i++){
			char cc = chars[i];
			if(cc == delimiter){
				String subS = str.substring(flag, i);
				list.add(subS);
				flag = i+1;
			}
		}
		String lastStr = str.substring(str.lastIndexOf(delimiter)+1, str.length());
		list.add(lastStr);
		//定义一个数组来放List里的字符串
		String[] arrSub = new String[list.size()];
		for(int i=0;i<list.size();i++){
			arrSub[i] = list.get(i);
			System.out.println(arrSub[i]);
		}
		return arrSub;
	}
	
	public static String round(String str,int digit){
		String[] arrStr = str.split("\\.");
		int decLen = arrStr[1].length();
		int roundInt = 0;
		int a = 0;
		int b = 0;
		//参数里小数位不能小于小数点后面的位数
		if(digit > decLen){
			System.out.println("输入 有误");
		}else{
			a = Integer.valueOf(arrStr[1].substring(0, digit));
			b = Integer.valueOf(arrStr[1].substring(digit, arrStr[1].length()));
			if(b>=5){
				roundInt = a + 1;
			}else{
				roundInt = a;
			}
		}
		return arrStr[0]+ "." + String.valueOf(roundInt);
	}
	
	
	public String[] getRandomCodes(char[] chars,int n,int m){
		int length = chars.length;
		if(chars==null || length==0||n<=0||m<=0){
			return null;
		}
		String[] resultStr = new String[m];
		Random random = new Random();
		int i=0;
		while(i<m){
			StringBuilder sb = new StringBuilder();
			for(int j=0;j<n;j++){
				sb.append(chars[random.nextInt(length)]);
			}
			boolean flag = true;
			if(i !=0){
				for(int j=0;j<i;j++){
					if(sb.toString().equals(resultStr[j])){
						flag = false;
					}
				}
			}
			if(flag){
				resultStr[i] = sb.toString();
				i++;
			}
		}
		return resultStr;
	} 
}
